﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Test2
{
    public partial class RobotLoad : Form
    {
        public RobotLoad()
        {
            InitializeComponent();
        }
        //这次不是502端口，也不是30003端口，而是29999端口
        URControlHandle URController = new URControlHandle();
        private void btnLoadCurrentProgram_Click(object sender, EventArgs e)
        {
            string NewProgram = txtProgramPath.Text;
            string Feedback = URController.Send_command_WithFeedback("load " + NewProgram);
            txtFeedback.Items.Add(Feedback);
        }

        private void RobotLoad_Load(object sender, EventArgs e)
        {
            //FilesINI ConfigController = new FilesINI();
            //string Target_IP = ConfigController.INIRead("UR控制参数", "RemoteIP", DefaultINIPath);
            //int Control_Port = 29999;

            //创建Dashboard客户端
            URController.Creat_client("192.168.2.3", 29999);

            //一开始连接到UR之后UR会主动发过来一条信息
            string Feedback = URController.No_command_WaitFeedback();
            txtFeedback.Items.Add(Feedback);
        }

        private void btnRunbtnRun_Click(object sender, EventArgs e)
        {
            string Feedback = URController.Send_command_WithFeedback("play");
            txtFeedback.Items.Add(Feedback);
        }

        private void btnPause_Click(object sender, EventArgs e)
        {
            string Feedback = URController.Send_command_WithFeedback("pause");
            txtFeedback.Items.Add(Feedback);
        }

        private void btnGetCurrentProgram_Click(object sender, EventArgs e)
        {
            string Feedback = URController.Send_command_WithFeedback("get loaded program");
            txtFeedback.Items.Add(Feedback);
        }
    }
}
